﻿@model ThereAreNoIrreplaceblePeople.Models.SearchViewModel

@{
    ViewBag.Title = "Index";
}



<h2>Search for Substitution</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Search by subject</legend>
		<div class="editor-label">
            Subject's name:
        </div>
		<div class="editor-field">
            @*@Html.DropDownListFor(model => model.Subjects)*@
		   @Html.DropDownListFor(model => model.SelectedSubject, new SelectList(Model.Subjects, "CourseCode", "CourseName"))
        </div>

		<div class="editor-label">
            Date:
        </div>
		<div class="editor-field">
            Year:
            @Html.TextBoxFor(model => model.Date.Year, new { style = "width: 50px;"}) 
            Month:
            @Html.TextBoxFor(model => model.Date.Month, new { style = "width: 50px;" })
            Day:
            @Html.TextBoxFor(model => model.Date.Day, new { style = "width: 50px;" })
            <br />
            Hour:
            @Html.TextBoxFor(model => model.Date.Hour, new { style = "width: 50px;" })
            Minutes:
            @Html.TextBoxFor(model => model.Date.Minute, new { style = "width: 50px;" })
        </div>

        <br />
        <div class="editor-label">
            Number of hours:
        </div>
		<div class="editor-field">
            @Html.TextBoxFor(model => model.Hours, new { style = "width: 50px;" })
        </div>

        <p>
            <input id="button" type="submit" value="Search" />
        </p>
    </fieldset>
}

@if (Model.Users.Count > 0)
{
<table>
    <tr>
        <th>
            Email
        </th>
        <th>
            FirstName
        </th>
        <th>
            LastName
        </th>
        <th>
            PhoneNumber
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.Users)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FirstName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PhoneNumber)
        </td>
        <td class="links">
            @Html.ActionLink("Send request", "SendRequest", new { receiver = item.Email, subjectName = Model.SelectedSubject, dt = Model.Date, numberOfHours = Model.Hours }) 
        </td>
    </tr>
}

</table>
}


<h2 style="color: Green; text-decoration: underline;">@ViewBag.Message</h2>
<!--
@*@using (Html.BeginForm("SendEmail", "Search"))
{
    <input type="submit" id="sendEmailButton" value="Send exemplary email" />
}*@
-->

